package com.dyb.springcloud.controller;

import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.Server;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
@Slf4j
public class PaymentController {

    private static final String INVOKE_URL="http://cloud-provider-payment";

    @Value("${server.port}")
    private String serverPort;

    @Resource
    private RestTemplate restTemplate;

    @GetMapping(value = "/consumer/payment")
    public String paymentInfo(){
        log.info("restTemplate ----> "+restTemplate.toString());
        log.info("端口号："+ serverPort +"------->开始发起远程调用");
        //Ribbon远程调用
        return restTemplate.getForObject(INVOKE_URL+"/payment/zk",String.class);

    }
}
